home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / bbs / cddk9606.zip / HEADERS.ARJ / MATH.INT < prev    next >
Text File  |  1996-06-14  |  14KB  |  563 lines

  1.  
  2. { ───────────────────────────────────────────────────────────────────────── }
  3. {  MATH: Mathematics                                                        }
  4. {  Copyright 1996 David Pinch ∙ All Rights Reserved Worldwide               }
  5. { ───────────────────────────────────────────────────────────────────────── }
  6.  
  7. UNIT Math;
  8.  
  9. {$B-} { . . . . . . . . . . . . . . . . . . . . Shortcut boolean evaluation }
  10. {$F+} { . . . . . . . . . . . . . . . . . . . .  Force far calls for safety }
  11. {$I-} { . . . . . . . . . . . . . . . . . . . Disable input/output checking }
  12. {$O+} { . . . . . . . . . . . . . . . . . . Allow this unit to be overlayed }
  13. {$Q-} { . . . . . . . . . . . . . .  Do not generate overflow-checking code }
  14. {$R-} { . . . . . . . . . . . . . . . . Do not generate range-checking code }
  15. {$S-} { . . . . . . . . . . . . . . . . Do not generate stack-checking code }
  16. {$X+} { . . . . . . . . . . . Extended syntax for pChars and function calls }
  17.  
  18. INTERFACE
  19.  
  20. TYPE
  21.  
  22.   { Turbo Pascal Real Types                                                 }
  23.   {                                                                         }
  24.   {   ┌────────────┬─────────────────────┬────────┬────┐                    }
  25.   {   │   Real     │ 2.9e-39..1.7e38     │ 11-12  │  6 │                    }
  26.   {   │ + Single   │ 1.5e-45..3.4e38     │  7-8   │  4 │                    }
  27.   {   │ + Double   │ 5.0e-324..1.7e308   │ 15-16  │  8 │                    }
  28.   {   │ + Extended │ 3.4e-4932..1.1e4932 │ 19-20  │ 10 │                    }
  29.   {   │ + Comp     │ -9.2e18..9.2e18     │ 19-20  │  8 │                    }
  30.   {   └────────────┴─────────────────────┴────────┴────┘                    }
  31.   {                                   + MathCo required                     }
  32.  
  33.   {$IFOPT N+}
  34.   Float = Extended;
  35.   {$ELSE}
  36.   Float = Real;
  37.   {$ENDIF}
  38.  
  39.   tComplex = OBJECT
  40.     a : Float;
  41.     b : Float;
  42.     PROCEDURE Add(CONST C:tComplex);
  43.     FUNCTION  Magnitude:Float;
  44.     PROCEDURE Multiply(CONST C:tComplex);
  45.     PROCEDURE Subtract(CONST C:tComplex);
  46.     END;
  47.  
  48.   pComplex = ^tComplex;
  49.  
  50.  
  51.   tFunction = FUNCTION (x:Float):Float;
  52.  
  53.  
  54. {#Start}
  55.  
  56.  
  57. { ─[ Angle Conversions ]─────────────────────────────────────────────────── }
  58.  
  59. FUNCTION Deg_Grd (CONST D:Float) : Float;
  60.   {
  61.   PURPOSE  : Converts degrees to gradians.
  62.  
  63.   SEE ALSO : Deg_Rad, Grd_Deg, Grd_Rad, Rad_Deg, Rad_Grd
  64.   }
  65.  
  66.  
  67. FUNCTION Deg_Rad (CONST D:Float) : Float;
  68.   {
  69.   PURPOSE  : Converts degrees to radians.
  70.  
  71.   SEE ALSO : Deg_Grd, Grd_Deg, Grd_Rad, Rad_Deg, Rad_Grd
  72.   }
  73.  
  74.  
  75. FUNCTION Grd_Deg (CONST G:Float) : Float;
  76.   {
  77.   PURPOSE  : Converts gradians to degrees.
  78.  
  79.   SEE ALSO : Deg_Grd, Deg_Rad, Grd_Rad, Rad_Deg, Rad_Grd
  80.   }
  81.  
  82.  
  83. FUNCTION Grd_Rad (CONST G:Float) : Float;
  84.   {
  85.   PURPOSE  : Converts gradians to radians.
  86.  
  87.   SEE ALSO : Deg_Grd, Deg_Rad, Grd_Deg, Rad_Deg, Rad_Grd
  88.   }
  89.  
  90.  
  91. FUNCTION Rad_Deg (CONST R:Float) : Float;
  92.   {
  93.   PURPOSE  : Converts radians to degrees.
  94.  
  95.   SEE ALSO : Deg_Grd, Deg_Rad, Grd_Deg, Grd_Rad, Rad_Grd
  96.   }
  97.  
  98.  
  99. FUNCTION Rad_Grd (CONST R:Float) : Float;
  100.   {
  101.   PURPOSE  : Converts radians to gradians.
  102.  
  103.   SEE ALSO : Deg_Grd, Deg_Rad, Grd_Deg, Grd_Rad, Rad_Deg
  104.   }
  105.  
  106.  
  107. { ─[ Area Functions ]────────────────────────────────────────────────────── }
  108.  
  109. FUNCTION Area_Circle(CONST Radius:Float):Float;
  110.   {
  111.   PURPOSE  : Calculates the area of a circle with the specified radius.
  112.  
  113.   NOTES    : Area = πr²
  114.  
  115.   SEE ALSO : Area_Ellipse, Area_Equilateral_Triangle, Area_Rectangle,
  116.              Area_Sector, Area_Square, Area_Trapezoid, Area_Triangle
  117.   }
  118.  
  119.  
  120. FUNCTION Area_Ellipse(CONST R1,R2:Float):Float;
  121.   {
  122.   PURPOSE  : Calculates the area of an ellipse with the specified focal
  123.              points.
  124.  
  125.   SEE ALSO : Area_Circle, Area_Equilateral_Triangle, Area_Rectangle,
  126.              Area_Sector, Area_Square, Area_Trapezoid, Area_Triangle
  127.   }
  128.  
  129.  
  130. FUNCTION Area_Equilateral_Triangle(CONST S:Float):Float;
  131.   {
  132.   PURPOSE  : Calculates the area of an equilateral triangle with the
  133.              given side length.
  134.  
  135.  
  136.                         √ 3
  137.   NOTES    :     Area = ─── S²
  138.                          4
  139.  
  140.   SEE ALSO : Area_Circle, Area_Ellipse, Area_Rectangle, Area_Sector,
  141.              Area_Square, Area_Trapezoid, Area_Triangle
  142.   }
  143.  
  144.  
  145. FUNCTION Area_Rectangle(CONST X,Y:Float):Float;
  146.   {
  147.   PURPOSE  : Calculates the area of a rectangle with the specified side
  148.              lengths.
  149.  
  150.   SEE ALSO : Area_Circle, Area_Ellipse, Area_Equilateral_Triangle,
  151.              Area_Sector, Area_Square, Area_Trapezoid, Area_Triangle
  152.   }
  153.  
  154.  
  155. FUNCTION Area_Sector(CONST Radius, Angle:Float):Float;
  156.   {
  157.   PURPOSE  : Calculates the area of a sector with the specified radius
  158.              and angle.
  159.  
  160.   SEE ALSO : Area_Circle, Area_Ellipse, Area_Equilateral_Triangle,
  161.              Area_Rectangle, Area_Square, Area_Trapezoid, Area_Triangle
  162.   }
  163.  
  164.  
  165. FUNCTION Area_Square(CONST Side:Float):Float;
  166.   {
  167.   PURPOSE  : Calculates the area of a square with the specified side length.
  168.  
  169.   NOTES    : Area = S²
  170.  
  171.   SEE ALSO : Area_Circle, Area_Ellipse, Area_Equilateral_Triangle,
  172.              Area_Rectangle, Area_Sector, Area_Trapezoid, Area_Triangle
  173.   }
  174.  
  175.  
  176. FUNCTION Area_Trapezoid(CONST A,B,H:Float):Float;
  177.   {
  178.   PURPOSE  : Calculates the area of a trapezoid with the specified
  179.              top, base and height.
  180.  
  181.   SEE ALSO : Area_Circle, Area_Ellipse, Area_Equilateral_Triangle,
  182.              Area_Rectangle, Area_Sector, Area_Square, Area_Triangle
  183.   }
  184.  
  185.  
  186. FUNCTION Area_Triangle(CONST Base,Height:Float):Float;
  187.   {
  188.   PURPOSE  : Calculates the area of a triangle with the specified base
  189.              and height lengths.
  190.  
  191.   NOTES    : Area = ½BH
  192.  
  193.   SEE ALSO : Area_Circle, Area_Ellipse, Area_Equilateral_Triangle,
  194.              Area_Rectangle, Area_Sector, Area_Square, Area_Triangle
  195.   }
  196.  
  197.  
  198. { ─[ Calculus ]──────────────────────────────────────────────────────────── }
  199.  
  200. FUNCTION Simpson(CONST y:tFUNCTION; CONST a,b,n:LongInt):Float;
  201.   {
  202.   PURPOSE  : Calculates the area under the curve of the given function,
  203.              using Simpson's approximation procedure.
  204.  
  205.   PARAMS   : y  =  A Turbo Pascal function: FUNCTION(x:Float):Float
  206.              a  =  Lower limit
  207.              b  =  Upper limit
  208.              n  =  Number of iterations
  209.   }
  210.  
  211.  
  212. { ─[ Circumference Functions ]───────────────────────────────────────────── }
  213.  
  214. FUNCTION Circum_Circle(CONST R:Float):Float;
  215.   {
  216.   PURPOSE  : Calculates the circumference of a circle with the given radius.
  217.  
  218.   SEE ALSO : Circum_Ellipse
  219.   }
  220.  
  221.  
  222. FUNCTION Circum_Ellipse(CONST R1,R2:Float):Float;
  223.   {
  224.   PURPOSE  : Calculates the circumference of an ellipse with the given
  225.              major and minor radii.
  226.  
  227.   SEE ALSO : Circum_Circle
  228.   }
  229.  
  230.  
  231. { ─[ Hyperbolic functions ]──────────────────────────────────────────────── }
  232.  
  233. FUNCTION COSH(CONST R:Float):Float;
  234.   {
  235.   PURPOSE  : Calculates the hyperbolic cosine of the argument.
  236.  
  237.   SEE ALSO : COTH, SECH, SINH, TANH
  238.   }
  239.  
  240.  
  241. FUNCTION COTH(CONST R:Float):Float;
  242.   {
  243.   PURPOSE  : Calculates the hyperbolic cotangent of the argument.
  244.  
  245.   SEE ALSO : COSH, SECH, SINH, TANH
  246.   }
  247.  
  248.  
  249. FUNCTION SECH(CONST R:Float):Float;
  250.   {
  251.   PURPOSE  : Calculates the hyperbolic secant of the argument.
  252.  
  253.   SEE ALSO : COSH, COTH, SINH, TANH
  254.   }
  255.  
  256.  
  257. FUNCTION SINH(CONST R:Float):Float;
  258.   {
  259.   PURPOSE  : Calculates the hyperbolic sine of the argument.
  260.  
  261.   SEE ALSO : COSH, COTH, SECH, TANH
  262.   }
  263.  
  264.  
  265. FUNCTION TANH(CONST R:Float):Float;
  266.   {
  267.   PURPOSE  : Calculates the hyperbolic tangent of the argument.
  268.  
  269.   SEE ALSO : COSH, COTH, SECH, SINH
  270.   }
  271.  
  272.  
  273. { ─[ Minimum/Maximum Functions ]─────────────────────────────────────────── }
  274.  
  275. FUNCTION MaxS(A,B:ShortInt):ShortInt;
  276.   {
  277.   PURPOSE  : Returns the larger of the two ShortInts.
  278.  
  279.   SEE ALSO : MinS, MaxB, MinB, MaxI, MinI, MaxW, MinW
  280.   }
  281.  
  282.  
  283. FUNCTION MinS(A,B:ShortInt):ShortInt;
  284.   {
  285.   PURPOSE  : Returns the lesser of the two ShortInts.
  286.  
  287.   SEE ALSO : MaxS, MaxB, MinB, MaxI, MinI, MaxW, MinW
  288.   }
  289.  
  290.  
  291. FUNCTION MaxB(A,B:Byte):Byte;
  292.   {
  293.   PURPOSE  : Returns the larger of the two bytes.
  294.  
  295.   SEE ALSO : MaxS, MinS, MinB, MaxI, MinI, MaxW, MinW
  296.